package com.tagtraum.perf.gcviewer;

import com.google.common.collect.Lists;
import java.util.List;

public enum SectionChangeBus
{
  INSTANCE;

  private final List<SectionChangeListener> listeners;

  private SectionChangeBus() {
    this.listeners = Lists.newArrayList();
  }

  public void switchSection(Object origin, String sectionName) {
    for (SectionChangeListener listener : this.listeners)
      listener.onChange(origin, sectionName);
  }

  public void subscribe(SectionChangeListener listener)
  {
    this.listeners.add(listener);
  }

  public void clear() {
    this.listeners.clear();
  }
}